/**
 * Report List Module.
 * 2015/05/04.
 */
define(['jquery'], function($) {
	var ReportList;
	ReportList = (function() {
		function ReportList() {
			this.init();
		}
		ReportList.prototype.init = function() {
			$('#list-loading-wrap').hide();
		};
		// ReportList.prototype.exportDataUpdate = function($dataTable, listTable) {
		// 	$dataTable.on('change keyup', 'input.table-head-filter', function(evt) {
	 //      var $me = $(this),
	 //        index = $me.data('index'),
	 //        meVal = $me.val();
	 //      evt.preventDefault();
	 //      listTable.column(index).search(meVal).draw();
	 //    });
		// };
		ReportList.prototype.requestData = function($reportFrm, $dataTable, listTable, configs) {
			// this.exportDataUpdate($dataTable, listTable);
			// console.log(configs);
			$reportFrm.submit(function(evt) {
	      var $me = $(this),
	      	$searchBtn = $me.find('.search-btn'),
	        filterStr = $me.serialize(),
	        searchStr = configs.dataListUrl + '?' + filterStr,
	        $reportDataExport = $('.report-data-export'),
	        $reportFilter = $dataTable.find('input.table-head-filter');
	      $reportFilter.val('');
	      $searchBtn.button('loading');
	      listTable.ajax.url(searchStr).load(function() {
	      	if ($reportDataExport.length === 1) {
	      		$reportDataExport.prop('href', configs.dataExportOp + '?' + filterStr);
	      	} else {
	      		$reportDataExport.eq(0).prop('href', configs.dataExportOp + '?' + filterStr + '&dataType=media');
	      		$reportDataExport.eq(1).prop('href', configs.dataExportOp + '?' + filterStr + '&dataType=buyer');
	      	}
	        $reportFilter.trigger('change');
	        $searchBtn.button('reset');
	      });
	      return false;
	    });
	    if(configs.initDataLoad) {
	    	$reportFrm.submit();
	    }
		};

		return ReportList;
	})();

	return ReportList;
});